<?php  
class ControllerModulePriceFilter extends Controller {
	protected function index() {
		$this->language->load('module/pricefilter');
		
    $this->data['heading_title'] = $this->language->get('heading_title');
		
		if (isset($this->request->get['price_id'])) {
			$parts = $this->request->get['price_id'];
		} else {
			$parts = '';
		}
		$this->data['price_id'] = $parts;
							
		$this->load->model('catalog/product');
		
		$this->data['categories'] = array();
					
		//$categories = $this->model_catalog_category->getCategories(0);
		$categories = array(
			0=>100000,
			1=>300000,
			2=>500000,
			3=>700000,
			4=>1000000,
		);
		
		$url = http_build_query($this->request->get);

		foreach ($categories as $key => $category) {
			if($key+1 < count($categories)){

				if(empty($parts)){
					$urlFilter = HTTP_SERVER.'index.php?'.$url.(empty($url)?'':'&').'price_id='.$category.'-'.$categories[$key+1];
				} else {
					$urlReplace = str_replace('price_id='.$parts,'price_id='.$category.'-'.$categories[$key+1],$url);
				  $urlFilter = HTTP_SERVER.'index.php?'.$urlReplace;
				} 
				$this->data['categories'][] = array(
					'price_id'    => $category.'-'.$categories[$key+1],
					'name'        => $this->currency->format($category).' - '.$this->currency->format($categories[$key+1]),
					'href'        => $urlFilter
				);
			}
		}
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/pricefilter.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/module/pricefilter.tpl';
		} else {
			$this->template = 'default/template/module/pricefilter.tpl';
		}
		
		$this->render();
  	}
}
?>